/* 获取元素 */
let nhk = document.querySelector(".nhk");
let input1 = nhk.children[0];
let input2 = nhk.children[2];
let input3 = nhk.children[4];
let submit = document.getElementById("submit");
console.log(submit);

input1.addEventListener("focus", function () {
    input1.style.boxShadow = " -2px 0px 2px 1px rgb(12, 143, 230),0px -2px 2px 1px rgb(12, 143, 230),2px 0px 2px 1px rgb(12, 143, 230),0px 2px 2px 1px rgb(12, 143, 230)"
})
input1.addEventListener("blur", function () {
    input1.style.boxShadow = "none"
})
input2.addEventListener("focus", function () {
    input2.style.boxShadow = " -2px 0px 2px 1px rgb(12, 143, 230),0px -2px 2px 1px rgb(12, 143, 230),2px 0px 2px 1px rgb(12, 143, 230),0px 2px 2px 1px rgb(12, 143, 230)"
})
input2.addEventListener("blur", function () {
    input2.style.boxShadow = "none"
})

/* 正则验证 */
//手机号的验证 
input1.oninput = function () {
    var reg = /^1\d{10}$/;
    if (reg.test(this.value)) {
        this.nextElementSibling.innerHTML = "";  
        arr[0] = true;   
    } else {
        this.nextElementSibling.innerHTML = "请输入正确的手机号";
        arr[0] = false;   
    }
}

var arr = ["请输入正确的手机号"];
//密码的规则
input2.oninput = function () {
    var reg = /^(\w|[\u2E80-\u9FFF]|!\w){4,20}$/
    //定义一个计数器
    var sum = 0;
    var hasnum = /\d/g
    if (hasnum.test(input2.value)) { 
        sum++;
    }
    var hasletter = /[a-z]/gi;
    if (hasletter.test(input2.value)) {
        sum++;
    }
    var special = /[^a-z\d]/gi
    if (special.test(input2.value)) {
        sum++;
    }
    switch (sum) {
        case 1:
            input2.nextElementSibling.innerHTML = "弱";
            break;
        case 2:
            input2.nextElementSibling.innerHTML = "中";
            break;
        case 3:
            input2.nextElementSibling.innerHTML = "强";
            break;
    }
}

